/*     */ package com.qmsk.business.info.operateType.controller;
/*     */ 
/*     */ import com.qmsk.business.info.operateType.dao.OperateTypeDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/operateType"})
/*     */ public class OperateTypeController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(OperateTypeController.class);
/*     */ 
/*     */   @Autowired
/*     */   private OperateTypeDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  49 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  51 */       Map params = new HashMap();
/*     */ 
/*  53 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  54 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  56 */       logger.error(e);
/*  57 */       ResponseUtils.setErrorMsgResponse(
/*  58 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  76 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  78 */       Map params = new HashMap();
/*     */ 
/*  80 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  81 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  83 */       logger.error(e);
/*  84 */       ResponseUtils.setErrorMsgResponse(
/*  85 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try
/*     */     {
/* 104 */       Map params = new HashMap();
/* 105 */       MapUtils.addToMap(params, "id", id);
/* 106 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/* 107 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 109 */       logger.error(e);
/* 110 */       ResponseUtils.setErrorMsgResponse(
/* 111 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/ltId/{ltId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfLargeTypeId(HttpServletRequest request, HttpServletResponse response, @PathVariable("ltId") Long ltId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 135 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 137 */       Map params = new HashMap();
/* 138 */       MapUtils.addToMap(params, "ltId", ltId);
/* 139 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 140 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 142 */       logger.error(e);
/* 143 */       ResponseUtils.setErrorMsgResponse(
/* 144 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 160 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 162 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 163 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 164 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 165 */         response);
/* 166 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 168 */       DbConnection.rollback();
/* 169 */       logger.error(e);
/* 170 */       ResponseUtils.setErrorMsgResponse(
/* 171 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 172 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 190 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 192 */       String[] strParams = id.split(",");
/* 193 */       int nResult = this.dao.deleteParams(strParams);
/* 194 */       DbConnection.commit();
/* 195 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 196 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 197 */         response);
/*     */     } catch (Exception e) {
/* 199 */       DbConnection.rollback();
/* 200 */       logger.error(e);
/* 201 */       ResponseUtils.setErrorMsgResponse(
/* 202 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 203 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 219 */     String id = request.getParameter("id");
/* 220 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 222 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 223 */       if (g == null) {
/* 224 */         ResponseUtils.setErrorMsgResponse(
/* 225 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 226 */           response);
/*     */       } else {
/* 228 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 229 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 230 */           RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 231 */           response);
/*     */       }
/* 233 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 235 */       DbConnection.rollback();
/* 236 */       logger.error(e);
/* 237 */       ResponseUtils.setErrorMsgResponse(
/* 238 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 239 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.operateType.controller.OperateTypeController
 * JD-Core Version:    0.5.3
 */